<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUserKnowledgeTable extends Migration
{

    protected $tableName = 'user_knowledge';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->comment('用户ID');
            $table->unsignedInteger('knowledge_id')->comment('知识点ID');
            $table->unsignedInteger('tag_id')->comment('标签ID');

            $table->timestamps();
            $table->softDeletes();

            $table->index('user_id');

        });
        DB::statement("ALTER TABLE `$this->tableName` comment '用户单词本表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
